package com.tool.image;

import com.tool.ModerateTask.TaskProgress;
import com.tool.role.RoleData;
import com.tool.tcp.GetTcpPath;
import com.tool.tcp.NewPart;
import com.tool.tcp.Sprite;
import com.tool.tcp.SpriteFactory;
import com.tool.tcpimg.*;
import come.tool.Fighting.FightingMixDeal;
import come.tool.Fighting.FightingMove2;
import come.tool.Fighting.Fightingimage;
import come.tool.Fighting.sidian;
import come.tool.handle.HandleState;
import io.netty.util.internal.StringUtil;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.come.Frame.AircraftJframe;
import org.come.Frame.TestPetJframe;
import org.come.Jpanel.FrameMessageChangeJpanel;
import org.come.Jpanel.TestSetupJpanel;
import org.come.Jpanel.ZhuJpanel;
import org.come.bean.*;
import org.come.control.JirenjiaobenchuliControl;
import org.come.entity.Fly;
import org.come.entity.RoleSummoning;
import org.come.model.Door;
import org.come.model.Robots;
import org.come.npc.TP;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.thread.TimeControlRunnable;
import org.come.until.*;

import javax.swing.*;
import java.awt.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;

/**
 * 人物属性
 *
 * @author Administrator
 */
public class ManimgAttribute {
    public static boolean ISTCP = true;
    public static boolean ISNAME = true;
    private RoleShow roleShow;
    private NpcInfoBean npc;// npc数据
    private MapMonsterBean mapMonsterBean;// 野怪数据
    private TaskProgress taskdata;// 任务怪数据
    private int leixing; // 0 玩家自己 1其他玩家 2npc 3召唤兽 4 宝宝 5 野怪 6任务怪
    private long time;
    private int dir;
    private NewPart part;
    // 用了判断是否在屏幕内
    private Image image;
    private int x, y;
    private int count;
    /**
     * 历史冒泡对话
     */
    private List<FloatPanel> chatPanels = new ArrayList<>();
    // 名称
    private String name;
    // 名
    private String[] names;
    // 称谓
    private String[] appellation;
    private String[] appellation1;
    // 明雷怪物绑定任务ID
    private String[] taskIds;
    /** 显示点击效果 */
    private static List<Effects> Effectslist = new ArrayList<>();
    //宝宝跟随
    private RoleSummoning roleSummoning;
    // 名字颜色
    private Color nameColor = null;
    //飞行器相关
    public static boolean isdaiji = false;
    public static boolean ISFLY = false;
    public static boolean IS = false;
    public static String flyskin;
    private flytcp flytcp=new flytcp("cloud1/stand");;
    private Flyruntcp flyruntcp=new Flyruntcp("cloud2/stand");
    private flywalktcp flywalktcp=new flywalktcp("cloud3/stand");
    public static int yys = 0;
    public static int lx = 99;

    public static String XNMSXZSXF = "1";
    public Color getNameColor() {
        return nameColor;
    }

    public void setNameColor(Color nameColor) {
        this.nameColor = nameColor;
    }

    public void setDefaultNameColor() {
        this.nameColor = null;
    }

    private int flyX = 0, flyY = 0;

    /** 修改人物皮肤 */
    public void changeskin(String skin) {
//		S:皮肤 X:特效 P:装饰品 J:足迹 B：翅膀 C:称谓特效
        boolean isZJ = false;
        part = null;

        if (roleShow != null) {
            if (roleShow.getSkin() != null && !roleShow.getSkin().equals("")) {
                String[] vs = roleShow.getSkin().split("\\|");
                for (int i = 0; i < vs.length; i++) {
                    if (vs[i].startsWith("X") || vs[i].startsWith("P")) {
                        String[] ts = vs[i].substring(1).split("_");
                        NewPart newPart = SpriteFactory.createPart("tx/tx" + ts[0], -2, Integer.parseInt(ts[1]), null);//

                        if (part == null) {
                            part = newPart;
                        } else {
                            part = part.addPart(newPart);
                        }
                    } else if (vs[i].startsWith("J")) {// 足迹
                        isZJ = true;
                        if (txZJ == null) {
                            txZJ = new TxZJ("tx/tx" + vs[i].substring(1));
                        } else {
                            txZJ.setSkin("tx/tx" + vs[i].substring(1));
                        }
                    } else if (vs[i].startsWith("S")) {// 皮肤
                        skin = vs[i].substring(1);
                    } else if (vs[i].startsWith("C")) {// 称谓特效
                        NewPart newPart = SpriteFactory.createPart("tx/" + vs[i].substring(1), -2, 6, null);

                        if (part == null) {
                            part = newPart;
                        } else {
                            part = part.addPart(newPart);
                        }
                    } else if (vs[i].startsWith("B")) {// 翅膀特效
                        String cb = vs[i].substring(1);
                        NewPart newPart = SpriteFactory.createPart("tx/" + cb + "0", -2, -5, null);
                        if (part == null) {
                            part = newPart;
                        } else {
                            part = part.addPart(newPart);
                        }
                        newPart = SpriteFactory.createPart("tx/" + cb + "1", -2, 5, null);
                        part = part.addPart(newPart);
                    }
                }
            }
        } else {
            String[] vs = skin.split("\\|");
            for (int i = 0; i < vs.length; i++) {
                if (vs[i].startsWith("C")) {// 称谓特效
                    NewPart newPart = SpriteFactory.createPart("tx/" + vs[i].substring(1), -2, 6, null);
                    if (part == null) {
                        part = newPart;
                    } else {
                        part = part.addPart(newPart);
                    }
                }
            }
            skin = vs[0];
        }

        if (skin != null && (roleShow == null||roleShow.getMount_id() == 0 || skin.length() < 10)) {
            if (roleShow!=null){
                if(roleShow.getFly_id()!=0){
                    String roleskin=null;
                    String roleskin1=roleShow.getSpecies_id().toString();
                    String []vs1= {"23002",
                            "20001", "21001", "21002", "21003", "20004", "20005", "20006", "20007", "20010", "21004",
                            "21005", "21006", "22001", "22002", "22004", "22006", "23005", "24001", "24002", "24003", "24004", "24005", "24006","20008"
                    };
                    String[] vs2={"2300205", "2000102", "2100112", "2100210", "2100310", "2000408", "2000503", "2000610", "2000701", "2001001", "2100409", "2100501", "2100608", "2200103", "2200201", "2200405", "2200811", "2300511", "2400101", "2400210", "2400311", "2400403", "2400512", "2400601","2000801"};
                    for (int i= vs1.length-1;i>=0;i--){
                        if (roleskin1.equals(vs1[i])){
                            roleskin=vs2[i];
                            break;
                        }	else roleskin=roleShow.getSpecies_id().toString();
                    }
                    Mythread mythread=new Mythread();

                    if(roleShow.getSkin()!=null) {
                        if(roleShow.getSkin().split("\\|").length>1) {
                            roleskin1 = roleShow.getSkin().split("\\|")[0].replace("S", "");
                        }else {
                            roleskin1 = roleShow.getSkin().replace("S", "");
                        }
                    }
                    NewPart	newPart =  SpriteFactory.createPart(roleskin1, 2, 1, null);
                    newPart.setFly(flyskin,2,true);

                    if (IS)
                        mythread.start();
                    if (part==null)
                        part=newPart;
                    else {part=part.addPart(newPart);

                    }
                }else {
                    NewPart newPart = SpriteFactory.createPart(skin, 2, 1, null);
                    if (part == null) {
                        part = newPart;
                    } else {
                        part = part.addPart(newPart);
                    }
                }}else {
                NewPart newPart = SpriteFactory.createPart(skin, 2, 1, "null");
                if (part == null) {
                    part = newPart;
                } else {
                    part = part.addPart(newPart);
                }
            }

//		} else if (roleShow.getMount_id() != 0) {//这一句可以上飞行器显示坐骑

        } else if (roleShow.getMount_id() != 0&& roleShow.getFly_id() == 0) {//这一句可以上飞行器自动隐藏坐骑

            NewPart newPart = SpriteFactory.createPart(((long) roleShow.getMount_id() << 40| roleShow.getSpecies_id().longValue()) , 2, 1, null);//
            if (part == null) {
                part = newPart;

            } else {
                part = part.addPart(newPart);
            }
        }  else if(roleShow.getFly_id()!=0){//
            String roleskin=null;
            String roleskin1=roleShow.getSpecies_id().toString();
            String []vs1= {"23002",
                    "20001", "21001", "21002", "21003", "20004", "20005", "20006", "20007", "20010", "21004",
                    "21005", "21006", "22001", "22002", "22004", "22006", "23005", "24001", "24002", "24003", "24004", "24005", "24006","20008"
            };
            String[] vs2={"2300205", "2000102", "2100112", "2100210", "2100310", "2000408", "2000503", "2000610", "2000701", "2001001", "2100409", "2100501", "2100608", "2200103", "2200201", "2200405", "2200811", "2300511", "2400101", "2400210", "2400311", "2400403", "2400512", "2400601","2000801"};
            for (int i= vs1.length-1;i>=0;i--){
                if (roleskin1.equals(vs1[i])){
                    roleskin=vs2[i];
                    break;
                }	else roleskin=roleShow.getSpecies_id().toString();
            }
            Mythread mythread=new Mythread();
            NewPart	newPart =  SpriteFactory.createPart(roleskin1, 2, 1, null);
            newPart.setFly(flyskin,2,true);

            if (IS)
                mythread.start();
            if (part==null)
                part=newPart;
            else part=part.addPart(newPart);


        }else {
            NewPart newPart = SpriteFactory.createPart(roleShow.getSpecies_id().longValue(), 2, 1, null);
            if (part == null) {
                part = newPart;
            } else {
                part = part.addPart(newPart);
            }
        }
        Mythread mythread2=new Mythread();
        if (isdaiji && !IS) {
            mythread2.start();
        }
        if (!isZJ) {
            txZJ = null;
        }
    }
    public class Mythread extends Thread{
        public 	Mythread(){

        }
        public void run(){
            for (int i=0;i<=140;i++) {
                if (IS){
                    if(yys<140) {
                        try {
                            Thread.sleep(40);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        yys = yys+i;
                    }
                    if(yys>140) {
                        yys = 140;
                    }
                    if(yys == 140) {
                        break;
                    }
                }else {
                    if(roleShow.getFly_id()==0) {
                        if(yys>0) {
                            try {
                                Thread.sleep(45);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                            yys = yys-i;
                        }
                    }
                    if(yys <= 0) {
                        yys = 0;
                        break;
                    }
                }
            }
            if(yys == 0 && AircraftJframe.getAircraftJframe().getaircraftJPanel().getBtnFight().getText().equals("待机")) {
                String mes = Agreement.getAgreement().rolechangeAgreement("F");
                roleShow.setFly_id(0);
                SendMessageUntil.toServer(mes);
                AircraftJframe.getAircraftJframe().getaircraftJPanel().getBtnFight().setText("飞行");
                ImageMixDeal.userimg.changeskin(null);
                ManimgAttribute.ISFLY=false;
                isdaiji = false;
            }
            IS=false;
            isdaiji=false;
        }
    }
    public boolean exit = true;
    public class Mythreadrun extends Thread{
        public 	Mythreadrun(){

        }

        public void run(){
            exit=false;

            Random m=new Random();
            int k=m.nextInt(30);
            int p=m.nextInt(8);
            int c=m.nextInt(50);
            if (c<20)
                Math.negateExact(p);
//			flyruntcp.addfly(roleShow.getX()-k*20,roleShow.getY()-p*20,dir);

            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            k=m.nextInt(9);
            p=m.nextInt(15);
            c=m.nextInt(50);
            if (c<20)
                Math.negateExact(p);
//			flywalktcp.addfly(roleShow.getX()+p*15,roleShow.getY()+k*15,dir);


            k=m.nextInt(10);
            p=m.nextInt(20);
            c=m.nextInt(50);
            if (c<20)
                Math.negateExact(p);
//			flytcp.addfly(roleShow.getX()+k*15,roleShow.getY()+p*15,dir);

            exit=true;

        }
    }
    /** 玩家的初始化方法 */
    public ManimgAttribute(RoleShow roleShow, int leixing) {
        super();
        try {
            this.name = roleShow.getRolename();
            this.names = AccessTeamInfoUntil.getss(name);
            this.appellation = AccessTeamInfoUntil.getss(roleShow.getTitle());
            this.appellation1 = AccessTeamInfoUntil.getss(roleShow.getTitle());
            this.leixing = leixing;
            this.roleShow = roleShow;
            initTeam();
            changeskin(null);
            //如果组队 不考虑跟随
//			if (ImageMixDeal.userimg.getRoleShow().getTeamInfo() == null || ImageMixDeal.userimg.getRoleShow().getTeamInfo().equals("")) {
            //宠物跟随
            if (CollectionUtils.isNotEmpty(roleShow.getShowRoleSummoningList())){
                ImageMixDeal.petMap.put(roleShow.getRolename(),roleShow.getShowRoleSummoningList().stream().filter(e->e.isShow())
                        .map(e->new ManimgAttribute(e,1)).collect(Collectors.toList()));
            }
//			}
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    //宠物跟随
    public void movePet(List<ManimgAttribute> pets){
        //如果组队 不考虑跟随
        //  if (ImageMixDeal.userimg.getRoleShow().getTeamInfo() == null || ImageMixDeal.userimg.getRoleShow().getTeamInfo().equals("")) {
        ManimgAttribute my = this;
        for (int i = 0; i < pets.size(); i++) {
            ManimgAttribute manimgAttribute = pets.get(i);
            if (manimgAttribute != null) {
                if (roleShow != null) {
                    if (manimgAttribute.getRoleShow() != null) {
                        manimgAttribute.bh(my.getmove());
                        my = manimgAttribute;
                    }else{
                        TestPetJframe.getTestPetJframe().getTestPetJpanel().getTestPetJpanel().getBtnpetyc().nochoose(null);
                    }
                }
            }
        }
        //}
    }
    //宠物跟随
    public ManimgAttribute(RoleSummoning roleSummoning, int leixing) {
        super();
        //如果组队 不考虑跟随
//		if (ImageMixDeal.userimg.getRoleShow().getTeamInfo() == null || ImageMixDeal.userimg.getRoleShow().getTeamInfo().equals("")) {
        try {
            this.name = roleSummoning.getSummoningname();
            this.names = AccessTeamInfoUntil.getss(name);
            this.leixing = leixing;
            this.roleSummoning = roleSummoning;
            part=roleSummoning.getPart();
            LoginResult loginResult = new LoginResult();
            loginResult.setX(0L);
            loginResult.setY(0L);
            loginResult.setGrade(0);
            loginResult.setTurnAround(roleSummoning.getTurnRount());
            RoleShow roleShow=new RoleShow(loginResult);

            this.roleShow=new RoleShow(loginResult);//
            this.getMoves();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
//		}
    }
    /** npc的初始化方法 */
    public ManimgAttribute(NpcInfoBean npcInfoBean) {
        super();
        try {
            changeskin(npcInfoBean.getNpctable().getSkin());
            this.name = npcInfoBean.getNpctable().getNpcname();
            this.names = AccessTeamInfoUntil.getss(name);
            this.leixing = 2;
            this.npc = npcInfoBean;
            x = Integer.parseInt(npc.getNpctable().getTx());
            y = Integer.parseInt(npc.getNpctable().getTy());
            this.appellation = AccessTeamInfoUntil.getss(npc.getNpctable().getTitle());
            this.appellation1 = AccessTeamInfoUntil.getss(npc.getNpctable().getTitleskin());
            this.dir = dirtiao(Integer.parseInt(npc.getNpctable().getDir()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /** npc喊话 */
    public void npcmsg() {
        String text = npc.getNpctable().getTicktxt();
        if (text == null || text.equals(""))
            return;
        String jg = npc.getNpctable().getTick();
        if (jg == null || jg.equals("") || jg.equals("0"))
            return;
        int jgtime = Integer.parseInt(jg) * 1000;
        if (time > jgtime) {
            time = 0;
            if (chatPanels.size() == 0)
                chatPanels.add(new FloatPanel(text));
            FrameMessageChangeJpanel.addtext(0, text, null, name);
        }
    }

    /** npc方向调整 */
    public int dirtiao(int dir) {
        if (dir == 1)
            return 0;
        else if (dir == 3)
            return 5;
        else if (dir == 5)
            return 1;
        else if (dir == 7)
            return 7;
        return 1;
    }

	/** 野怪初始化5 */
	public ManimgAttribute(MapMonsterBean mapMonsterBean, String[] names, String[] appellation, String taskIds) {
		try {//修改怪物名字颜色的问题
			this.name = mapMonsterBean.getRobotname();
			this.names = names;
			this.appellation = appellation;
			changeskin(mapMonsterBean.getRobotskin());
			this.leixing = 5;
			if (mapMonsterBean.getRobotTitle() != null && !mapMonsterBean.getRobotTitle().equals("")) {
				Random random = new Random();
				Color[] cl = {UIUtils.COLOR_NAME, UIUtils.COLOR_NAME1, UIUtils.COLOR_NAME2, UIUtils.COLOR_NAME3, UIUtils.COLOR_NAME4};
				this.setNameColor(cl[random.nextInt(cl.length - 1)]);
				this.setNameColor(UIUtils.COLOR_NAME);
			}
			this.mapMonsterBean = mapMonsterBean;
			if (mapMonsterBean.getRobotTitle() != null && mapMonsterBean.getRobotTitle() != "") {
				this.appellation = AccessTeamInfoUntil.getss(mapMonsterBean.getRobotTitle());
			}
			x = mapMonsterBean.getX();
			y = mapMonsterBean.getY();
		} catch (Exception e) {

		}
	}

	public ManimgAttribute(MapMonsterBean mapMonsterBean, String[] names) {
		try {//修改怪物名字颜色的问题
			this.name = mapMonsterBean.getRobotname();
			this.names = names;
			String robotskin = mapMonsterBean.getRobotskin();
			if (StringUtils.isNotBlank(mapMonsterBean.getTitleSkin())) {
				robotskin += "|C" + mapMonsterBean.getTitleSkin();
			}
			changeskin(robotskin);
			this.leixing = 5;

			if (StringUtils.isNotBlank(mapMonsterBean.getRobotTitle())) {
				this.appellation = AccessTeamInfoUntil.getss(mapMonsterBean.getRobotTitle());
				Random random = new Random();
				Color[] cl = {UIUtils.COLOR_NAME, UIUtils.COLOR_NAME1, UIUtils.COLOR_NAME2, UIUtils.COLOR_NAME3, UIUtils.COLOR_NAME4};
				this.setNameColor(cl[random.nextInt(cl.length - 1)]);
				this.setNameColor(UIUtils.COLOR_NAME);
			}
			this.mapMonsterBean = mapMonsterBean;
			x = mapMonsterBean.getX();
			y = mapMonsterBean.getY();
		} catch (Exception e) {

        }
    }

    /**
     * 任务怪初始化6
     */
    public ManimgAttribute(TaskProgress progress) {
        try {
            this.name = progress.getDName();
            if (StringUtils.isNotEmpty(progress.getTitle())) {
                this.appellation = new String[]{progress.getTitle()};
            }
            this.names = AccessTeamInfoUntil.getss(name);
            Robots robots = UserMessUntil.getRobot(progress.getDId() + "");
            changeskin(robots != null ? robots.getRobotskin() : "100");
            this.leixing = 6;
            this.taskdata = progress;
            x = progress.getX();
            y = progress.getY();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /** 判断是否在画布内 */
    public PathPoint isdraw() {
        PathPoint pathPoint = null;
        if (roleShow != null) {
            if(roleShow.getFly_id()>0 && leixing == 0) {
                lx = leixing;
                pathPoint = Util.mapmodel.path(roleShow.getX(), roleShow.getY()-yys);
            }else if(roleShow.getFly_id()>0 && leixing == 1) {
                lx = leixing;
                pathPoint = Util.mapmodel.path(roleShow.getX(), roleShow.getY()-140);
            }else if(roleShow.getFly_id() == 0 && leixing == 1) {
                lx = leixing;
                pathPoint = Util.mapmodel.path(roleShow.getX(), roleShow.getY());
            }else if(roleShow.getFly_id() == 0 && leixing == 0) {
                lx = leixing;
                pathPoint = Util.mapmodel.path(roleShow.getX(), roleShow.getY()-yys);
            }
        } else {
            pathPoint = Util.mapmodel.path(x, y);
        }
        return pathPoint;
    }

    public static NewPart part3=null;
    public static NewPart part4=  null;//SpriteFactory.createPart("骰子全/1点", -2, 5, null);;
    public static NewPart part5=null;//SpriteFactory.createPart("骰子全/骰子转动特效1", -2, 5, null);;;
    public static List<NewPart>partList=new ArrayList<>();
    boolean m=true;
    public static 	boolean start=false;
    public class  Mythreadrun1 extends Thread{
        private  Graphics g2;
        private int x;
        public 	Mythreadrun1(Graphics g,int x ){
            this.g2=g;
            this.x=x;
        }
        public void run(){

            m=false;
            if (part3!=null)
                if (ScrenceUntil.Screen_x >= 1366){
                    part3.draw(g2,x + 250, 300, dir, time);
                }else if (ScrenceUntil.Screen_x >= 1024){
                    part3.draw(g2, x + 100, 300, dir, time);
                }else {
                    part3.draw(g2, x, 300, dir, time);
                }
            part5=SpriteFactory.createPart("骰子全/骰子转动特效1", -2, 5, null);;;
            m=true;

        }
    }
    public class  Mythreadrun2 extends Thread{
        private  Graphics g2;
        private int x;
        public 	Mythreadrun2(Graphics g,int x ){
            this.g2=g;
            this.x=x;
        }
        public void run(){
            long k= (long) (time/1.5);
            m=false;
            if (part5!=null)
                if (ScrenceUntil.Screen_x >= 1366){
                    part5.draw(g2, x + 250, 300 + 50 + 20, dir, k);
                }else if (ScrenceUntil.Screen_x >= 1024){
                    part5.draw(g2, x + 100, 300 + 50 + 20, dir, k);
                }else {
                    part5.draw(g2, x, 300 + 50 + 20, dir, k);
                }
            m=true;

        }
    }
    public static String zhongjiang=null;
    public static String[] dianshu= {"1","2","3"};
    public class  Dingshi extends Thread{
        private  Graphics g2;
        private int x;
        private int p;
        public 	Dingshi(int p ){
            this.p=p;
        }
        public void run(){
            start=true;
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            String b="骰子全/"+p+"点";
            part4=SpriteFactory.createPart(b, -2, 5, null);
        }
    }
    public class  Dingshi2 extends Thread{
        private  Graphics g2;
        private int x;
        private boolean p;
        public 	Dingshi2(boolean p ){
            this.p=m;
        }
        public void run(){

            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            part4=null;
            part5=null;
            part3=null;
            partList.clear();
            start=false;
//			if (zhongjiang!=null)
//				SendMessageUntil.toServer(GsonUtil.getGsonUtil().getgson().toJson("jiangli-"+zhongjiang));
//
//			zhongjiang=null;

        }
    }
    // TODO 画图，画所有人物怪物NPC包括自己
    /** 传入画笔 所要显示的位置 */
    public boolean Drawing(Graphics g2, long DieTime) {

        ImageMixDeal.ismove = false;
        PathPoint pathPoint = isdraw();

        if (roleShow != null && roleShow.getFlyskin() != null) {
            part.setFly(roleShow.getFlyskin(), 2,true);
            part.setFlyShadow(roleShow.getFlyskin() + "1", 2);
        }
        if (pathPoint == null) {
            part.recycle();
            ImageMixDeal.ismove = true;
            return false;
        }
        time += DieTime;
        if (m&&part3!=null&&part5==null){//黄大小

            for (int i=0;i<=2;i++){
                Mythreadrun1 mythreadrun1=new  Mythreadrun1(g2,i*250+200);
                mythreadrun1.start();
            }

        }
        if (part5!=null&&part4==null){//黄大小

            for (int i=0;i<=2;i++){
                Mythreadrun2 mythreadrun2=new  Mythreadrun2(g2,i*250+200);
                mythreadrun2.start();
            }
            Dingshi dingshi=new Dingshi(Integer.parseInt(dianshu[0]));
            dingshi.start();
        }
        if (part4!=null){//黄大小

		/*	for (int i=0;i<=4;i++){
				Mythreadrun2 mythreadrun=new  Mythreadrun2(g2,200+i*150);
				mythreadrun.start();
			}*/	//part4.draw(g2,100, 300, dir, time);
            Dingshi2 dingshi=new Dingshi2(false);
            dingshi.start();
            for (int s=0;s<=partList.size()-1;s++)
                partList.get(s).draw(g2,s*200+200, 300, dir, time);


        }
        if (!ISTCP && leixing == 1) {
            part.recycle();
            if (ISNAME) {
                drawfonts(g2, pathPoint.getX(), pathPoint.getY());
            }
            if (roleShow != null) {
                drawTou(g2, pathPoint);
            }
            ImageMixDeal.ismove = true;
            return true;
        }
        if (ISNAME || leixing != 1) {
            drawfonts(g2, pathPoint.getX(), pathPoint.getY());
        }
        if (part != null) {
            if (Util.mapmodel.zhezhao(pathPoint.getX(), pathPoint.getY())) {
                if (ISFLY) {
                    part.draw(g2, pathPoint.getX(), pathPoint.getY(), dir, time, 1.0f);
                } else {
                    part.draw(g2, pathPoint.getX(), pathPoint.getY(), dir, time, 0.6f);

                }
                if (leixing == 0 && roleShow.getDivineRune() || leixing == 1 && roleShow.getDivineRune()) {
                    drawDivineWalks(part, g2, pathPoint);
                }
            } else {
                part.draw(g2, pathPoint.getX(), pathPoint.getY(), dir, time);
                if (leixing == 0 && roleShow.getDivineRune() || leixing == 1 && roleShow.getDivineRune()) {
                    drawDivineWalks(part, g2, pathPoint);
                }
            }
            draw(g2, pathPoint.getX(), pathPoint.getY());

            if (roleShow != null) {
                drawTou(g2, pathPoint);
            } else if (mapMonsterBean != null && mapMonsterBean.getHP() != null && mapMonsterBean.getHP().getX() > 0) {
                int hp_bai = (int) (75D * mapMonsterBean.getHP().getX() / mapMonsterBean.getHP().getY());
                if (hp_bai > 75) {
                    hp_bai = 75;
                } else if (hp_bai < 0) {
                    hp_bai = 0;
                }
                g2.drawImage(Fightingimage.xuelans[0].getImage(), pathPoint.getX() - 35, pathPoint.getY() - 125, 75, 5, null);
                g2.drawImage(Fightingimage.xuelans[1].getImage(), pathPoint.getX() - 35, pathPoint.getY() - 125, hp_bai, 5, null);
            }
            if (txZJ != null) {
                txZJ.draw(g2, DieTime);
            }
            if (ISFLY) {
                flytcp.draw(g2, DieTime / 2);
                flywalktcp.draw(g2, DieTime / 2);
                flyruntcp.draw(g2, DieTime / 2);
            }
        }
        ImageMixDeal.ismove = true;
        return true;
    }

    private int divineWalkCount = 1;
    public void addmove() {//组队间距，跟随宝宝间距 初始值13
        Mythreadrun mythreadrun=new Mythreadrun();
        if (getMoves().size() >= 13) {
            if (part.getAct() == 1) {
                sidian sidian = moves.remove(0);
                sidian.setsidian(roleShow.getX(), roleShow.getY(), dir, part.getAct());
                if(XNMSXZSXF!=null) {

                    switch (XNMSXZSXF) {
                        case "1":
                            if (leixing == 0 && divineWalkCount % 10 == 0 && roleShow.getDivineRune() || leixing == 1 && divineWalkCount % 10 == 0 && roleShow.getDivineRune()) {
                                DivineWalk divineWalk = new DivineWalk(null, roleShow.getX(), roleShow.getY(), dir);
                                if (list.size() >= 6) {
                                    list.add(divineWalk);
                                    list.remove(1);

                                } else {
                                    list.add(divineWalk);
                                }
                                divineWalkCount = 0;
                            }
                            break;
                        case "2":
                            if (leixing == 0 && divineWalkCount % 20 == 0 && roleShow.getDivineRune() || leixing == 1 && divineWalkCount % 20 == 0 && roleShow.getDivineRune()) {
                                DivineWalk divineWalk = new DivineWalk(null, roleShow.getX(), roleShow.getY(), dir);
                                if (list.size() >= 6) {
                                    list.add(divineWalk);
                                    list.remove(1);

                                } else {
                                    list.add(divineWalk);
                                }
                                divineWalkCount = 0;
                            }
                            break;
                        case "3":
                            if (leixing == 0 && divineWalkCount % 30 == 0 && roleShow.getDivineRune() || leixing == 1 && divineWalkCount % 30 == 0 && roleShow.getDivineRune()) {
                                DivineWalk divineWalk = new DivineWalk(null, roleShow.getX(), roleShow.getY(), dir);
                                if (list.size() >= 6) {
                                    list.add(divineWalk);
                                    list.remove(1);

                                } else {
                                    list.add(divineWalk);
                                }
                                divineWalkCount = 0;
                            }
                            break;
                    }
                }
                if (txZJ != null) {
                    txZJ.addZJ(roleShow.getX(), roleShow.getY(), dir);
                }
                if (ISFLY) {
                    Random m = new Random();
                    int k = m.nextInt(30);
                    int p = m.nextInt(8);
                    int c = m.nextInt(50);
                    if (c < 20)
                        Math.negateExact(p);
//					flyruntcp.addfly(roleShow.getX()-k*20,roleShow.getY()+p*20,dir);

//					mythreadrun.start();

                }


                moves.add(sidian);
                divineWalkCount += 1;
            } else {
                if (ISFLY) {

                    mythreadrun.start();
//					Random m=new Random();
//					int k=m.nextInt(30);
//					int p=m.nextInt(8);
//					int c=m.nextInt(50);
//					if (c<20)
//						Math.negateExact(p);
//					flywalktcp.addfly(roleShow.getX()-k*20,roleShow.getY()-p*20,dir);
//	飞行器云
                }
                getmove().setW(2);
                list.clear();
            }
        } else {
            if (part.getAct() == 1 && txZJ != null) {

                txZJ.addZJ(roleShow.getX(), roleShow.getY()+10, dir);

            }
            if (ISFLY) {

                mythreadrun.start();

            }
            moves.add(new sidian(roleShow.getX(), roleShow.getY(), dir, part.getAct()));

        }
    }

    /** 玩家头上动画 */
    private void drawTou(Graphics g2, PathPoint pathPoint) {
        // 判断是否在战斗
        if (roleShow.getFighting() != 0) {
            Sprite mouse = SpriteFactory.Prepare(GetTcpPath.PK);
            if (mouse != null) {
                mouse.updateToTime(time, 0);
                mouse.draw(g2, pathPoint.getX() - 15, pathPoint.getY() - 110);
            }
        } else {
            if (roleShow.getCaptian() == 1) {
                Sprite mouse = SpriteFactory.Prepare(GetTcpPath.LIN);
                if (mouse != null) {
                    mouse.updateToTime(time, 0);
                    if(roleShow.getMount_id()>7) {
                        mouse.draw(g2, pathPoint.getX(), pathPoint.getY() - 165);
                    }else {
                        mouse.draw(g2, pathPoint.getX(), pathPoint.getY() - 125);
                    }
                }
            }
        }
    }

    private long movejiange = 0;
    private List<sidian> moves;

    public List<sidian> getMoves() {
        if (moves == null)
            moves = new ArrayList<>();
        return moves;
    }

    public void setMoves(List<sidian> moves) {
        this.moves = moves;
    }

    public sidian getmove() {
        if (getMoves().size() == 0)
            moves.add(new sidian(roleShow.getX(), roleShow.getY(), dir, part.getAct()));
        return moves.get(0);
    }

    /**
     * 重置
     */
    public void CZmove() {
        getMoves();
        for (int i = 0; i < moves.size(); i++) {
            moves.get(i).setsidian(roleShow.getX(), roleShow.getY(), dir, part.getAct());
        }
    }
    //神行符效果
    private List<DivineWalk> list = new ArrayList<>();

    public void drawDivineWalks(NewPart part, Graphics g2, PathPoint pathPoint) {
        for (int i = 0; i < list.size(); i++) {
            DivineWalk divineWalk = list.get(i);
            PathPoint pathPoint1 = Util.mapmodel.path(divineWalk.getX(), divineWalk.getY());
            if (pathPoint1 != null)
                part.draw(g2, pathPoint1.getX(), pathPoint1.getY() - flyY, divineWalk.getDir(), time, i * 0.15f);
        }

    }

    private String[] teams;
    String [] teams2;

    public void initTeam() {
        teams = null;
        if (roleShow.getTroop_id() == null || roleShow.getTeamInfo() == null || roleShow.getTeamInfo().equals("")) {

            teams = new String[]{roleShow.getRolename()};
            teams2=null;
            roleShow.setCaptian(0);



        } else {
            teams = roleShow.getTeamInfo().split("\\|");
            if (JirenjiaobenchuliControl.name==null){
                if (!teams[0].equals(roleShow.getRolename())) {
                    teams = null;
                }
            }else {

                if (!teams[0].equals(JirenjiaobenchuliControl.duizhang.getRoleShow().getRolename())) {
                    teams = null;
                }
            }
            roleShow.setCaptian(teams != null ? 1 : 0);

        }
        if (roleShow.getCaptian()==1&&JirenjiaobenchuliControl.name!=null){
            if (!roleShow.getRolename().equals(JirenjiaobenchuliControl.name))
                roleShow.setCaptian(0);
        }
        if (leixing == 0 && teams == null&&JirenjiaobenchuliControl.name==null) {
            TimeControlRunnable.removeScript();
        }
    }

    private TxZJ txZJ;

    /** 移动 */
    public void move(long time) {
        if (teams != null) {
            addmove();
            if (JirenjiaobenchuliControl.name!=null){
                //roleShow.setPlayer_Paths(ImageMixDeal.Playerimgmap.get(JirenjiaobenchuliControl.name).getRoleShow().getPlayer_Paths());
                DoorRect();
            }
            if (roleShow.getPlayer_Paths().size() <= 1) {
                setType(2);
            } else {
                setType(1);
//				if(roleShow.getMount_id() > 7) {
//					int grade = Util.moveGrade;//飞行坐骑移动速度
//					if(grade>=10 && grade<20) {
//						movejiange = FightingMove2.getmovetime(this, roleShow,0.24+0.02, getMovejiange(time), dir);
//					}else
//					if(grade>=20 && grade<30) {
//						movejiange = FightingMove2.getmovetime(this, roleShow,0.24+0.04, getMovejiange(time), dir);
//					}else
//					if(grade==30) {
//						movejiange = FightingMove2.getmovetime(this, roleShow,0.24+0.08, getMovejiange(time), dir);
//					}else {
//						movejiange = FightingMove2.getmovetime(this, roleShow,0.24, getMovejiange(time), dir);
//					}
//				}else {
//					movejiange = FightingMove2.getmovetime(this, roleShow, 0.24, getMovejiange(time), dir);
//
//				}
//				double m=roleShow.getMount_id()==7?0.25:0.24;
                double m=roleShow.getMount_id()==7?0.20:0.20;
                //飞行器移动速度
                if(roleShow.getFly_id()!=0) {
                    if(ZhuJpanel.getListFly()!=null && ZhuJpanel.getListFly().size()>0) {
                        for(Fly fly:ZhuJpanel.getListFly()) {
                            if(fly.getFlytid()==roleShow.getFly_id()) {
                                if(fly.getFlystate()>0) {
                                    //飞行器速度
                                    //m=0.24+0.24/10*fly.getFlystate();
                                    m=0.18+0.18/4*fly.getFlystate();
                                }
                            }
                        }
                    }
                }
                double l = 0;
                if (m >= 1.09)
                    l = 0.29;
                else l = m;
                if (roleShow.getDivineRune()) {
                    l *= 1.8;
                }
//				两种传送传的正常
//				movejiange = FightingMove2.getmovetime(this, roleShow, roleShow.getMount_id() == 7 ? 0.28 : 0.24, getMovejiange(time), dir);
                movejiange = FightingMove2.getmovetime(this, roleShow, l, getMovejiange(time), dir);

                if (JirenjiaobenchuliControl.name==null){
                    if (leixing == 0) {
                        DoorRect();
                    }
                }else {
                    if (leixing == 1) {
                        DoorRect();
                    }
                }
            }
            ManimgAttribute my = this;
            for (int i = 1; i < teams.length; i++) {
                ManimgAttribute manimgAttribute = ImageMixDeal.huoquLogin(teams[i]);
                if (manimgAttribute != null) {
                    manimgAttribute.bh(my.getmove());
                    my = manimgAttribute;
                }
            }
        }
    }


    /** 左键移动 */
    public void movezou(long time) {
        if (teams != null) {
            addmove();
            if (roleShow.getPlayer_Paths().size() <= 1) {
                setType(2);
                Util.ZOU = true; // Util.ZOU = false; 参数=false 有其他玩家在左键还是跑的原因
            } else {
                if(leixing == 0) {
                    if(roleShow.getMount_id() > 0) {
                        setType(1);
                    }else {
                        setType(0);
                    }
//					movejiange = FightingMove2.getmovetime(this, roleShow, roleShow.getMount_id() > 7 ? 0.20 : 0.14,
                    movejiange = FightingMove2.getmovetime(this, roleShow, roleShow.getMount_id() > 7 ? 0.17 : 0.11,
                            getMovejiange(time), dir);
                    if (leixing == 0) {
                        DoorRect();
                    }
                }else {
                    setType(1);
//					movejiange = FightingMove2.getmovetime(this, roleShow, roleShow.getMount_id() > 7 ? 0.24 : 0.24,
                    movejiange = FightingMove2.getmovetime(this, roleShow, roleShow.getMount_id() > 7 ? 0.17 : 0.11,
                            getMovejiange(time), dir);
                    if (leixing == 0) {
                        DoorRect();
                    }
                }
                if (leixing == 0) {
                    DoorRect();
                }
            }
            ManimgAttribute my = this;
            for (int i = 1; i < teams.length; i++) {
                ManimgAttribute manimgAttribute = ImageMixDeal.huoquLogin(teams[i]);
                if (manimgAttribute != null) {
                    manimgAttribute.bh(my.getmove());
                    my = manimgAttribute;
                }
            }
        }
    }


    /** 野怪移动 */
    //TODO 怪物移动数据
    public void move2(long time) {
        if (mapMonsterBean.getFollow() != null) {
            ManimgAttribute attribute = ImageMixDeal.huoquLogin(mapMonsterBean.getFollow());
            if (attribute != null) {
                GSM(attribute.getmove());
                return;
            }
        }
        if (mapMonsterBean.getMovePath() == null || mapMonsterBean.getType() != 0) {

        } else if (mapMonsterBean.getMovePath().isMove(this, time, dir)) {
            setType(2);
            mapMonsterBean.setMovePath(null);
        }
    }

    /** 队员坐标变化 */
    public void bh(sidian sidian) {
        addmove();
        roleShow.setX(sidian.getX());
        roleShow.setY(sidian.getY());
        setDir(sidian.getZ());
        setType(sidian.getW());
    }

    /** 跟随处理 */
    public void GS(sidian sidian) {
        x = sidian.getX();
        y = sidian.getY();
        setDir(sidian.getZ());
        setType(sidian.getW());
    }

    /** 野怪跟随处理 */
    public void GSM(sidian sidian) {
        x = sidian.getX() + 5;
        y = sidian.getY() + 5;
        setDir(sidian.getZ());
        setType(sidian.getW());
    }

    /** 判断是否进入door矩阵内 */
    public void DoorRect() {
        if (JirenjiaobenchuliControl.name!=null){
            int size=0;
            if (ImageMixDeal.Playerimgmap.size()!=0)
                if (ImageMixDeal.Playerimgmap.get(JirenjiaobenchuliControl.name)!=null)
                    if(ImageMixDeal.Playerimgmap.get(JirenjiaobenchuliControl.name).getRoleShow().getPlayer_Paths()!=null){
                        size = ImageMixDeal.Playerimgmap.get(JirenjiaobenchuliControl.name).getRoleShow().getPlayer_Paths().size();
                    }
            //int size = ImageMixDeal.Playerimgmap.get(JirenjiaobenchuliControl.name).getRoleShow().getPlayer_Paths().size();
            if (size > 1) {
                PathPoint point = ImageMixDeal.Playerimgmap.get(JirenjiaobenchuliControl.name).getRoleShow().getPlayer_Paths().get(size-1);
                if (Math.abs(point.getX() - ImageMixDeal.Playerimgmap.get(JirenjiaobenchuliControl.name).getRoleShow().getX()) > 81 || Math.abs(point.getY() - ImageMixDeal.Playerimgmap.get(JirenjiaobenchuliControl.name).getRoleShow().getY()) > 81) {
                    // 寻路途中的路径如果不是最终路径则不通过传送
                    return;
                }
            }Door door=null;
            if (ImageMixDeal.Playerimgmap.size()==0||ImageMixDeal.Playerimgmap.get(JirenjiaobenchuliControl.name)==null){

            }else
                door = Util.mapmodel.tp(ImageMixDeal.Playerimgmap.get(JirenjiaobenchuliControl.name).getRoleShow().getX(), ImageMixDeal.Playerimgmap.get(JirenjiaobenchuliControl.name).getRoleShow().getY());
            if (door == null)
                return;

            ImageMixDeal.Playerimgmap.get(JirenjiaobenchuliControl.name).getRoleShow().getPlayer_Paths().clear();
            TP.tp(door, 0);
        }else {
            int size = roleShow.getPlayer_Paths().size();
            if (size > 1) {
                PathPoint point = roleShow.getPlayer_Paths().get(size-1);
                if (Math.abs(point.getX() - roleShow.getX()) > 81 || Math.abs(point.getY() - roleShow.getY()) > 81) {
                    // 寻路途中的路径如果不是最终路径则不通过传送
                    return;
                }
            }
            Door door = Util.mapmodel.tp(roleShow.getX(), roleShow.getY());
            if (door == null)
                return;
            roleShow.getPlayer_Paths().clear();
            TP.tp(door, 0);
        }
    }
    public void draw(Graphics g, int x, int y) {
        if (chatPanels.size() != 0) {
            int py = part.getPy();
            if (py != -1) {// 人物冒泡对话内容
                int chatY = y - py;
                for (int i = chatPanels.size() - 1; i >= 0; i--) {
                    FloatPanel chatPanel = chatPanels.get(i);
                    if (shouldDisplay(chatPanel)) {
                        int chatX = x - chatPanel.getWidth() / 2;
                        chatY -= chatPanel.getHeight() + 2;
                        g.translate(chatX, chatY);
                        chatPanel.paint(g);
                        g.translate(-chatX, -chatY);
                    } else {
                        chatPanel.remove();
                        chatPanels.remove(i);
                    }
                }
            }
        }
    }

    public void draweffects(Graphics g) {
        for (int i = Effectslist.size() - 1; i >= 0; i--) {
            Effects effects = Effectslist.get(i);
            effects.addTime(15);
            if (EffectsDisplay(effects)) {
                PathPoint pathPoint = Util.mapmodel.path(Effectslist.get(i).getX(), Effectslist.get(i).getY());
                if (pathPoint == null) {
                    continue;
                }
                Sprite sprite1 = SpriteFactory.Prepare(GetTcpPath.getMouseTcp(effects.getEffectsName()));
                if (sprite1 == null) {
                    continue;
                }
                sprite1.updateToTime(effects.getTime(), 0);
                sprite1.draw(g, pathPoint.getX(), pathPoint.getY());
            } else {
                Effectslist.remove(i);
            }
        }
    }

    public static boolean shouldDisplay(FloatPanel chatPanel) {
        return Util.getTime() - chatPanel.getCreateTime() < Util.TIME_CHAT;
    }

    public static boolean EffectsDisplay(Effects effects) {
        if (effects.getEffectsName().equals("升级")) {
            return effects.getTime() < Util.TIME_CHAT / 2;
        }
        return effects.getTime() < Util.TIME_CHAT / 10;
    }

    // 徽章图片
    public static Image[] hzImgs = new Image[6];
    static {
        hzImgs[0] = new ImageIcon("img/head/hz_0.png").getImage();
        hzImgs[1] = new ImageIcon("img/head/hz_1.png").getImage();
        hzImgs[2] = new ImageIcon("img/head/hz_2.png").getImage();
        hzImgs[3] = new ImageIcon("img/head/hz_3.png").getImage();
        hzImgs[4] = new ImageIcon("img/head/hz_4.png").getImage();
        hzImgs[5] = new ImageIcon("img/head/hz_5.png").getImage();
    }

    public static Image getHzImg(int i) {
        if (i >= hzImgs.length) {
            i = hzImgs.length - 1;
        }
        return hzImgs[i];
    }

    public static void main(String[] args) {

    }

    /**
     * 画字体
     */
    int size1;
    private final ImageIcon shenshou = new ImageIcon("inkImg/button/tubiao.png");
    //人物名字
    public void drawfonts(Graphics g, int x, int y) {
        if (names == null) {
            return;
        }
        Graphics2D g2d = (Graphics2D) g.create();
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        boolean zhezhao = Util.mapmodel.zhezhao(x, y);
        float f = zhezhao ? 0.2F : 0.8F;
        g2d.setComposite(AlphaComposite.getInstance(3, f));
        g2d.setFont(UIUtils.nameFont);//修改NPC名字跟模型距离
//		g2d.setFont(UIUtils.TEXT_HYK161);
        g2d.setFont(TestSetupJpanel.nameFont);//字体切换
        int textY = y + 50;
        if (size1 == 0) {
            size1 = g2d.getFontMetrics().stringWidth(name) / 2;
        }

        int textX = x - size1;

        if (leixing == 0 || leixing == 1) {
            if (leixing == 0 && roleShow.getFlyskin()!=null || leixing == 1 && roleShow.getFlyskin()!=null) {
                if (roleShow.getSkill_id() != null) {
                    Image hz = getHzImg(roleShow.getSkill_id());
                    g2d.drawImage(hz, textX - 30, textY - 27, null);
                }
            }else{
                if (roleShow.getSkill_id() != null) {
                    Image hz = getHzImg(roleShow.getSkill_id());
                    g2d.drawImage(hz, textX - 30, textY - 34, null);
                }
            }
            if (leixing == 0 && roleShow.getFlyskin()!=null || leixing == 1 && roleShow.getFlyskin()!=null) {
                textY += 9;
            }else{
                textY += 3;
            }
            FontMetrics fm = g2d.getFontMetrics();
            for (int i = 0; i < names.length; i++) {

                // 黑色底
                g2d.setColor(UIUtils.COLOR_NAME16);
                g2d.drawString(names[i], textX+1, textY-17);

                // 彩色底
                g2d.setColor(UIUtils.getDarkColor(roleShow.getTurnAround()));
                g2d.drawString(names[i], textX+1, textY-17);
                // 字面
                g2d.setColor(UIUtils.getcolor(roleShow.getTurnAround()));
                g2d.drawString(names[i], textX, textY-18);
                g2d.drawString(names[i], textX, textY-18);
                textX += fm.stringWidth(names[i]) - 1;
            }

            if (Util.hideTitle) {
                if (appellation != null && roleShow.getTitle() != null) {
                    textY -= 19;
                    textX = x - g2d.getFontMetrics().stringWidth(roleShow.getTitle()) / 2;

                    for (int i = 0; i < appellation.length; i++) {
                        g2d.setColor(UIUtils.COLOR_NAME16);
                        g2d.drawString(appellation[i], textX + 1, textY-17);
                        g2d.setColor(UIUtils.COLOR_NAME11);
                        g2d.drawString(appellation[i], textX + 1, textY-17);
                        g2d.setColor(UIUtils.COLOR_NAME10);
                        g2d.drawString(appellation[i], textX, textY-18);
                        textX += fm.stringWidth(appellation[i]) - 1;
                    }
                }
            }
        }

        else {

            // TODO 1名字错位调整
            if (npc != null && npc.getNpctable() != null && !StringUtil.isNullOrEmpty(npc.getNpctable().getSkin())) {
                if ("300057".equals(npc.getNpctable().getSkin())) {
                    textX -= 15;
                }
                if ("300056".equals(npc.getNpctable().getSkin())) {
                    textX += 10;
                }
                if ("400062".equals(npc.getNpctable().getSkin())) {
                    textX += 17;
                }
            }

            if (appellation != null) {
                textY -= 5;
            } else {
                textY -= 20;
            }
            FontMetrics fm = g2d.getFontMetrics();
            for (int i = 0; i < names.length; i++) {
                // 黑色底
                g2d.setColor(UIUtils.COLOR_NAME16);
                g2d.drawString(names[i], textX+1, textY + 1);
                // 彩色底
                g2d.setColor(UIUtils.COLOR_NAME13);
                g2d.drawString(names[i], textX+1, textY + 1);
                // 字面
                g2d.setColor(nameColor == null ? UIUtils.COLOR_NAME12 : nameColor); // TODO NPC名字变色
                g2d.drawString(names[i], textX, textY);
                g2d.drawString(names[i], textX, textY);
                textX += fm.stringWidth(names[i]) - 1;
            }
            if (appellation != null) {
                if (npc != null) {
                    textX = x - g2d.getFontMetrics().stringWidth(npc.getNpctable().getTitle()) / 2;
                } else if (mapMonsterBean != null) {
                    textX = x - g2d.getFontMetrics().stringWidth(mapMonsterBean.getRobottitle()) / 2;// TODO 野怪称谓
                }
                for (int i = 0; i < appellation.length; i++) {
                    g2d.setColor(UIUtils.COLOR_NAME16);
                    g2d.drawString(appellation[i], textX + 1, textY - 19);
                    g2d.setColor(UIUtils.COLOR_NAME15);
                    g2d.drawString(appellation[i], textX + 1, textY - 19);
                    g2d.setColor(UIUtils.COLOR_NAME14);
                    g2d.drawString(appellation[i], textX, textY - 20);
                    textX += fm.stringWidth(appellation[i]) - 1;
                }
            }
            if (appellation1 != null) {
                // 获取并绘制NPC称谓
                if (npc != null && npc.getNpctable() != null && npc.getNpctable().getTitleskin() != null) {
                    String title = npc.getNpctable().getTitleskin(); // 获取称号
                    g2d.drawImage(shenshou.getImage(), x - 40, y - 140, null); // 绘制图标，y-40 确保图标位置
                    int titleWidth = g2d.getFontMetrics().stringWidth(title);
                    int textX1 = x + 10 + (shenshou.getIconWidth() - titleWidth) / 2; // 计算称谓的居中X坐标
                    g2d.setColor(UIUtils.COLOR_NAME6);
                    g2d.drawString(title, textX1 - 48, y - 109); // 在图标上绘制称号
                    g2d.setColor(UIUtils.COLOR_RCode); // 设置NPC称号颜色
                    g2d.drawString(title, textX1 - 48, y - 109); // 在图标上绘制称号
                    g2d.setColor(UIUtils.COLOR_RCode);
                    g2d.drawString(title, textX1 - 48, y - 109); // 在图标上绘制称号
                }
            }
        }



        g2d.dispose();
    }

    /**
     * 添加对话内容
     *
     * @return
     */
    public void Dialogue(String text) {
        if (FightingMixDeal.State == HandleState.USUAL) {
            chatPanels.add(new FloatPanel(text));
        } else {
            FightingMixDeal.Dialogue(roleShow.getRolename(), text);
        }
    }

    public void Dialogue1(String text, String name, BigDecimal id, String aaa, int bbb) {//  FloatPanel  聊天框宽度       NChatControl   聊天信息交互
        StringBuffer buffer = new StringBuffer();
        if (name != null && id != null) {

            if (aaa != null) {

                InputBean inputBean = new InputBean();
                inputBean.setType(1);
                inputBean.setId(id);
                final LoginResult login = RoleData.getRoleData().getLoginResult();
                if (StringUtils.isNotBlank(aaa)) {
                    inputBean.setGoodNum(aaa);
                    inputBean.setGoodNumType(String.valueOf(bbb));
                }
                if (StringUtils.isNotBlank(inputBean.getGoodNum())) {
                    inputBean.setName("[" + name);
                } else {
                    inputBean.setName("[" + name + "]");
                }
                inputBean.setColor("G");
                buffer.append("#V");
                buffer.append(GsonUtil.getGsonUtil().getgson().toJson(inputBean));
                buffer.append("#L");


                if (FightingMixDeal.State == HandleState.USUAL) {
                    chatPanels.add(new FloatPanel(buffer.toString() + text));
                } else {
                    FightingMixDeal.Dialogue(roleShow.getRolename(), buffer.toString() + text);
                }

            } else {


                buffer.append("#R#V");
                buffer.append("{\"type\":5,\"id\":");
                buffer.append(id);

                buffer.append(",\"name\":\"[");
                buffer.append(name);


                buffer.append("]\",\"color\":\"G\"}");
                buffer.append("#L#W");


                if (FightingMixDeal.State == HandleState.USUAL) {
                    chatPanels.add(new FloatPanel(buffer.toString() + text));
                } else {
                    FightingMixDeal.Dialogue(roleShow.getRolename(), buffer.toString() + text);
                }


            }


        } else {

            if (FightingMixDeal.State == HandleState.USUAL) {
                chatPanels.add(new FloatPanel(text));
            } else {
                FightingMixDeal.Dialogue(roleShow.getRolename(), text);
            }

        }

    }


    public void Dialogue122(String text, String name, BigDecimal id) {//不带靓号正常

        if (name != null && id != null) {
            StringBuffer buffer = new StringBuffer();

            buffer.append("#R#V");
            buffer.append("{\"type\":5,\"id\":");
            buffer.append(id);

            buffer.append(",\"name\":\"[");
            buffer.append(name);


            buffer.append("]\",\"color\":\"G\"}");
            buffer.append("#L#W");


            if (FightingMixDeal.State == HandleState.USUAL) {
                chatPanels.add(new FloatPanel(buffer.toString() + text));
            } else {
                FightingMixDeal.Dialogue(roleShow.getRolename(), buffer.toString() + text);
            }

        } else {

            if (FightingMixDeal.State == HandleState.USUAL) {
                chatPanels.add(new FloatPanel(text));
            } else {
                FightingMixDeal.Dialogue(roleShow.getRolename(), text);
            }

        }

    }

    public NewPart getPart() {
        return part;
    }

    public void setPart(NewPart part) {
        this.part = part;
    }


    /**
     * 添加特效内容
     *
     * @return
     */
    public static void addEffects(String text, int x, int y) {
        for (int i = 0; i < Effectslist.size(); i++) {
            if (!Effectslist.get(i).getEffectsName().equals(text))
                continue;
            Effectslist.get(i).setX(x);
            Effectslist.get(i).setY(y);
            Effectslist.get(i).setTime(0);
            return;
        }
        Effectslist.add(new Effects(text, x, y));
    }

    public RoleShow getRoleShow() {
        return roleShow;
    }

    public void setRoleShow(RoleShow roleShow) {
        this.roleShow = roleShow;
        initTeam();
    }

    public MapMonsterBean getMapMonsterBean() {
        return mapMonsterBean;
    }

    public void setMapMonsterBean(MapMonsterBean mapMonsterBean) {
        this.mapMonsterBean = mapMonsterBean;
    }

    public int getDir() {
        return dir;
    }

    public void setDir(int dir) {
        this.dir = dir;
    }

    public int getType() {
        return part.getAct();
    }

    public void setType(int type) {
        if (this.part.getAct() == type) {
            return;
        }
        this.part.setAct(type);
    }

    public long getMovejiange(long movejiange) {
        return this.movejiange += movejiange;
    }

    public void setMovejiange(long movejiange) {
        this.movejiange = movejiange;
    }

    public NpcInfoBean getNpc() {
        return npc;
    }

    public void setNpc(NpcInfoBean npc) {
        this.npc = npc;
    }

    public long getTime() {
        return time;
    }

    public void setTime(long time) {
        this.time += time;
    }

    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.size1 = 0;
        this.name = name;
        this.names = AccessTeamInfoUntil.getss(this.name);
    }

    public TaskProgress getTaskdata() {
        return taskdata;
    }

    public void setTaskdata(TaskProgress taskdata) {
        this.taskdata = taskdata;
    }

    public String[] getNames() {
        return names;
    }

    public void setNames(String[] names) {
        this.names = names;
    }

    public String[] getAppellation() {
        return appellation;
    }

    public void setAppellation(String chang) {
        this.appellation = AccessTeamInfoUntil.getss(chang);
    }

    public String[] getTeams() {
        return teams;
    }
    public String[] getAppellation1() {
        return appellation1;
    }

    public void setAppellation1(String chang) {
        this.appellation1 = AccessTeamInfoUntil.getss(chang);
    }
    public void setTeams(String[] teams) {
        this.teams = teams;
    }

    public int getLeixing() {
        return leixing;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public String[] getTaskIds() {
        return taskIds;
    }

    public void setTaskIds(String[] taskIds) {
        this.taskIds = taskIds;
    }

    /**
     * 判断是否点击内
     *
     * @return
     */
    public boolean isContains(int x, int y) {
        if (leixing == 0 && roleShow.getFlyskin()!=null || leixing == 1 && roleShow.getFlyskin()!=null){
            if (roleShow != null) {
                return part.contains(x - roleShow.getX(), y - roleShow.getY()+120);
            } else {
                return part.contains(x - this.x, y - this.y);
            }
        }else {
            if (roleShow != null) {
                return part.contains(x - roleShow.getX(), y - roleShow.getY());
            } else {
                return part.contains(x - this.x, y - this.y);
            }
        }
    }
    public  boolean get(){return ISFLY;}

    public  void setISFLY(boolean ISFLY){this.ISFLY=ISFLY;}
//	public RoleSummoning getRoleSummoning() {
//		return roleSummoning;
//	}

//	public void setRoleSummoning(RoleSummoning roleSummoning) {
//		this.roleSummoning = roleSummoning;
//	}

}
